import type { App } from 'vue'
import { useUserInfoStore } from '@/stores/userInfo'

const power = {
  install(app: App) {
    app.directive('power', {
      mounted(el, binding) {
        const userStore = useUserInfoStore()
        // 获取 服务器返回的按钮数组
        const buttons = userStore.userInfo.buttons

        if (!buttons.includes(binding.value)) {
          el.parentNode.removeChild(el)
        }
      }
    })
  }
}

export default power
